window['isRegister'] = false

function copyLinkContent_(str, that) {
  var oInput = document.createElement("input"); //创建隐形input
  oInput.value = str; //
  document.body.appendChild(oInput);
  oInput.select();
  document.execCommand("Copy");
  oInput.remove();
  return that.$message.success('复制成功');
}

const registerDBEvent = {
  data(){
    return {
      isRegister:false
    }
  },
  mounted() {
    if(window['isRegister'] == false){
      document.addEventListener('DOMContentLoaded', (event) => {
        const element = document.getElementById('app');
        element.addEventListener('dblclick', this.onDoubleClick);
      });
      window['isRegister']  = true
    }
  },
  methods:{
    onDoubleClick(e){
      let isExecute = false
      let tempVal = ''
      const element = e.target
      const value = element.getAttribute('use-data-title') || element.getAttribute('title')
      if(!this.$IS.isNullOrUnDef(value) && !this.$IS.isEmpty(value)){
        tempVal = value
        isExecute = true
        console.log('======1======>',tempVal);

      }
      const htmlLabel = element.getAttribute('use-data-title-v')
      if(isExecute==false && !this.$IS.isNullOrUnDef(htmlLabel) && !this.$IS.isEmpty(htmlLabel)){
        tempVal = element.innerText
        isExecute = true
        console.log('======2======>',tempVal);

      }
      // if(isExecute==false){
      //   tempVal = element.innerText
      //   if( !this.$IS.isNullOrUnDef(tempVal) && !this.$IS.isEmpty(tempVal)){
      //     isExecute = true
      //   }else {
      //     isExecute = false
      //   }
      //   console.log('======3======>',tempVal);
      // }

      if(isExecute==true){
        copyLinkContent_(tempVal,this)
      }
      console.log('双击事件=============>',e,value,htmlLabel,tempVal,element);
    }
  }
}


export default {
  install(Vue) {
    Vue.mixin(registerDBEvent);
  }
}
